home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / DJGPP / LGP250S1.ZIP / src / libgplus.5 / libgplus / vms / genclass.tpu < prev    next >
Text File  |  1991-06-28  |  2KB  |  50 lines

  1.  
  2.    PROCEDURE pat_replace (
  3.       oldstring, !
  4.       newstring)  !
  5.       LOCAL range2, count ;
  6.       position (beginning_of (current_buffer)) ;
  7.       count := 0 ;
  8.       LOOP
  9.          range2 := search_quietly (oldstring, FORWARD, EXACT) ;
  10.          EXITIF range2 = 0 ;
  11.          position (beginning_of (range2)) ;
  12.          erase (range2) ;
  13.          copy_text (newstring) ;
  14.          count := count + 1 ;
  15.          ENDLOOP ;
  16.       IF (count > 0) THEN
  17.          message (fao('Replaced pattern !UL time!%S', count)) ;
  18.       ENDIF ;
  19.    ENDPROCEDURE ;
  20.     
  21.    new_string1 := read_line ("type1: ") ;
  22.    new_file1 := substr(new_string1,1,1) ;
  23.    mode_string1 := read_line ("type&1: ") ;
  24.    new_string2 := read_line ("type2: ") ;
  25.    new_file2 := substr(new_string2,1,0) ;
  26.    mode_string2 := read_line ("type&2: ") ;
  27.    filename := GET_INFO (COMMAND_LINE, 'file_name') ;
  28.    LOOP
  29.       exp_filename := FILE_SEARCH (filename) ;
  30.       EXITIF exp_filename = "" ;
  31.       mainbuffer := CREATE_BUFFER (exp_filename, exp_filename) ;
  32.       position (mainbuffer) ;
  33.       execute ("pat_replace (""<T>."",new_file1)") ;
  34.       execute ("pat_replace (""<T>"", new_string1)") ;
  35.       execute ("pat_replace (""<T&>"",mode_string1)") ;
  36.       IF LENGTH (new_string2) > 0
  37.         THEN
  38.         execute ("pat_replace (""<C>."", new_file2)") ;
  39.         execute ("pat_replace (""<C>"", new_string2)") ;
  40.         execute ("pat_replace (""<C&>"",mode_string2)") ;
  41.         ENDIF;
  42.       IF get_info (mainbuffer, "modified") THEN
  43.          write_file (mainbuffer)
  44.       ELSE
  45.          message ('No changes made.') ENDIF ;
  46.       delete (mainbuffer) ;
  47.       ENDLOOP ;
  48.    quit ;
  49.  
  50.